#include <bits/stdc++.h>
using namespace std;
#define N 100005
typedef long long ll;
ll T;
ll n, m, L, V;
struct Cars
{
    ll d, v, a;
    ll l, r;
} ca[N];
struct Dec
{
    ll d, car, id;
} p[N];
bool cavis[N];
bool pvis[N];
ll sum, ans;
vector<ll> tmp;
bool cmp(const Dec &x, const Dec &y)
{
    if (x.car == y.car)
        return x.d < y.d;
    return x.car > y.car;
}
bool cmp2(const Dec &x, const Dec &y)
{
    return x.d < y.d;
}
void solve1()
{
    for (int i = 1; i <= n; i++)
    {
        if (p[m].d < ca[i].d)
            continue;
        if (ca[i].v * ca[i].v + 2 * ca[i].a * (p[m].d - ca[i].d) > V * V)
            cavis[i] = 1, ans = 1;
    }
    for (int i = 1; i <= n; i++)
        if (cavis[i])
            sum++;
    printf("%lld ", sum);
    printf("%lld", m - ans);
    puts("");
}
void solve3()
{
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (p[j].d < ca[i].d)
                continue;
            if (ca[i].v * ca[i].v + 2 * ca[i].a * (p[j].d - ca[i].d) > V * V)
            {
                if (!cavis[i])
                    ca[i].l = j;
                ca[i].r = j;
                p[j].car++;
                cavis[i] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        if (cavis[i])
            sum++;
    printf("%lld ", sum);
    for (int i = 1; i <= m; i++)
    {
        bool flag = 0;
        sort(p + i, p + 1 + m, cmp);
        tmp.clear();
        if (!p[i].car)
            break;
        for (int j = 1; j <= n; j++)
        {
            if (cavis[j] && ca[j].l <= p[i].id && p[i].id <= ca[j].r)
            {
                if (!flag)
                    ans++;
                flag = 1;
                cavis[j] = 0;
                tmp.push_back(j);
            }
        }
        for (auto &&car : tmp)
        {
            for (int j = i + 1; j <= m; j++)
            {
                if (p[j].d < ca[car].d)
                    continue;
                if (ca[car].v * ca[car].v + 2 * ca[car].a * (p[j].d - ca[car].d) > V * V)
                    p[j].car--;
            }
        }
    }
    printf("%lld", m - ans);
    puts("");
}
void solve()
{
    memset(p, 0, sizeof(p));
    memset(ca, 0, sizeof(ca));
    memset(cavis, 0, sizeof(cavis));
    memset(pvis, 0, sizeof(pvis));
    sum = ans = 0;
    bool f1 = 1, f2 = 1, f3 = 1;
    scanf("%lld%lld%lld%lld", &n, &m, &L, &V);
    for (int i = 1; i <= n; i++)
        scanf("%lld%lld%lld", &ca[i].d, &ca[i].v, &ca[i].a);
    for (int i = 1; i <= n; i++)
    {
        if (ca[i].a)
            f1 = 0;
        if (ca[i].a < 0)
            f2 = 0;
        if (ca[i].a > 0)
            f3 = 0;
    }
    for (int i = 1; i <= m; i++)
        scanf("%lld", &p[i].d), p[i].id = i;
    if (f1 || f2)
        solve1();
    else
        solve3();
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld", &T);
    while (T--)
        solve();
    return 0;
}
